package com.wct.genetic;

import java.util.*;

/**
 * @author WEI
 * @date 2018/5/27 13:48
 */

public class TspMain {

	public static void main(String[] args) {

		// 城市列表
		List<City> cityList = CityTool.getCityList("data1.txt");

		// 城市数量
		int cityCount = cityList.size();
		// 城市距离矩阵
		int[][] disMatrix = CityTool.getCityDisMatrix(cityList);
		TspGenetic genetic = new TspGenetic(cityCount, disMatrix);

		// 初始种群个数，初始种群越大，得到优解所需的进化代数越大
		int initNum = 20;
		// 初始种群
		List<TspSolution> tspSolutionList = genetic.getSolutionList(initNum);
		// 遍历初始种群
		System.out.println("初始种群: " + initNum + " 个");
		for (TspSolution s : tspSolutionList) {
			System.out.println(s.toString());
		}
		
		new TspThread2("Thread2",genetic, tspSolutionList).run();
	}
}
